package com.power.controller;

import com.alibaba.fastjson.JSON;
import com.power.common.Contants;
import com.power.ov.ResultData;
import com.power.pojo.Defect;
import com.power.service.impl.InspeServiceimpl;
import com.power.service.inspeService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.BufferedReader;
import java.io.IOException;
import java.sql.SQLException;

/**
 * Created with IntelliJ IDEA.
 * User: 李辽
 * Date: 2020/10/11 15:17
 * Description:
 * Version: V1.0
 */
@WebServlet("/Edit_CarriedInspe.do")
public class Edit_CarriedInspe extends HttpServlet {
    @Override
    protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        BufferedReader br = request.getReader();
        String s = br.readLine();
        Defect defect = JSON.parseObject(s, Defect.class);
        inspeService inspeService = new InspeServiceimpl();
        ResultData resultData = new ResultData();
        try {
            int result = inspeService.Edit_CarriedInspe(defect);
            resultData.setCode(Contants.SUCCESS);
            resultData.setMsg("回执上传成功");
        } catch (SQLException e) {
            e.printStackTrace();
            resultData.setCode(Contants.FAILURE );
            resultData.setMsg("系统出小差了，请稍后再试");
        }

        response.getWriter().write(JSON.toJSONString(resultData));
        response.getWriter().flush();
        response.getWriter().close();
        System.out.println("进入添加缺陷后台："+defect.toString());
        System.out.println("进入添加缺陷后台：");
    }
}





















